package com.outdoor.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.outdoor.model.entity.Team;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 团队数据访问接口
 * 
 * @author OutdoorTeam
 * @date 2025-05-18
 */
@Mapper
public interface TeamMapper extends BaseMapper<Team> {
    
    /**
     * 查询团队成员ID列表
     * 
     * @param teamId 团队ID
     * @return 成员ID列表
     */
    @Select("SELECT user_id FROM team_members WHERE team_id = #{teamId} AND is_deleted = 0")
    List<Long> selectTeamMemberIds(@Param("teamId") Long teamId);
    
    /**
     * 添加团队成员
     * 
     * @param teamId 团队ID
     * @param userId 用户ID
     */
    @Insert("INSERT INTO team_members (team_id, user_id, join_time) VALUES (#{teamId}, #{userId}, NOW())")
    void insertTeamMember(@Param("teamId") Long teamId, @Param("userId") Long userId);
} 